//
//  TabViewController.m
//  OAPro
//
//  Created by wucha on 2018/5/16.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "TabViewController.h"
#import "MainViewController.h"
#import "SeatViewController.h"
#import "MineViewController.h"
#import "LoginViewController.h"
#import "OrdinaryUserMainViewController.h"
#import "ManagementMainViewController.h"

@interface TabViewController ()

@end

@implementation TabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeIndex:) name:@"TabChange" object:nil];
    UIViewController *mainViewController = nil;
#ifdef ManagementModel
    mainViewController = [[ManagementMainViewController alloc] init];

#else
    mainViewController = [[OrdinaryUserMainViewController alloc] init];

#endif
    SeatViewController *seatViewController = [[SeatViewController alloc] init];
    MineViewController *mineViewController = [[MineViewController alloc] init];
    
    [self addTitle:@"首页" icon:@"homeicon" selectIcon:@"home_select" controller:mainViewController];
    [self addTitle:@"机位" icon:@"scheduleicon" selectIcon:@"schedule_select" controller:seatViewController];
    [self addTitle:@"我的" icon:@"mineicon" selectIcon:@"mine_select" controller:mineViewController];

}

-(void)changeIndex:(NSNotification*)notification{
    int index = [notification.object intValue];
//    if (index == 2) {
//        LoginViewController *loginViewController = [[LoginViewController alloc] init];
//        [self presentViewController:loginViewController animated:NO completion:nil];
//    }else{
        self.selectedIndex = index;

//    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
